package com.ruizhong.PIW.controller;

import com.ruizhong.PIW.entity.TWindow;
import com.ruizhong.PIW.service.WindowService;
import com.ruizhong.PIW.utils.Result;
import com.ruizhong.PIW.utils.ResultCode;
import com.ruizhong.PIW.vo.CalculateVO;
import com.ruizhong.PIW.vo.ListObjectVO;
import com.ruizhong.PIW.vo.StyleVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/window")
@CrossOrigin
@Slf4j
public class WindowController {

    @Autowired
    private WindowService windowService;

    @PostMapping("/saveWindows")
    public Result saveWindows(@RequestBody StyleVO styleVO){
            windowService.saveWindows(styleVO);
        return new Result<>(ResultCode.success,"保存成功",null);
    }

    @PostMapping("/submitUpdateStyle")
    public Result submitUpdateStyle(@RequestBody StyleVO styleVO){
        windowService.submitUpdateStyle(styleVO);
        return new Result<>(ResultCode.success,"保存成功",null);
    }

    @PostMapping("/calculateStyle")
    public Result calculateStyle(@RequestBody CalculateVO calculateVO){
        List<TWindow> calculateResult=windowService.calculateStyle(calculateVO);
        return new Result(ResultCode.success,null,calculateResult);
    }
}
